package com.example.edu.controller;



import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.example.edu.entity.subject.OneSubject;
import com.example.edu.service.SubjectService;
import com.example.utils.Result;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-06-29
 */
@RestController
@RequestMapping("/edu")
public class SubjectController {
	
	@Autowired
	private SubjectService subjectService;
	
	@PostMapping("/subject")
	public Result addSubject(MultipartFile file) {
		
		subjectService.saveSubject(file,subjectService);
		
		return Result.ok();
	}
	
	@GetMapping("/subject")
	public Result listSubject() {
		
		List<OneSubject> oneSubList = subjectService.listSubject();
		
		return Result.ok().data("oneSubjects", oneSubList);
	}

}

